package Tools;

import java.io.Serializable;
import java.util.ArrayList;

public class Node implements Serializable{

	
	int[] key;
	ArrayList<Node> links;
	
	
	public Node() {
		key = new int[4];
		links = new ArrayList<Node>();
	}
	
	public Node(int[] x){
		this();
		key = x;
	}
	
	public Node(int x1, int x2, int x3, int x4){
		this();
		key[0] = x1;
		key[1] = x2;
		key[2] = x3;
		key[3] = x4;
	}
	
	public void set(int index, int value){
		key[index] = value;
	}
	
	public int get(int index){
		return key[index];
	}
	
	public boolean contains2(){
		return key[0] == 2 || key[1] == 2 || key[2] == 2 || key[3] == 2;
	}
	
	public boolean isValid(){
		return key[0] +  key[1] + key[2] + key[3] > 1;
	}
	
	public Node clone(){
		return new Node(key[0], key[1], key[2], key[3]);
	}
	
	public String toString(){
		return "["+key[0]+" "+key[1]+" "+key[2]+" "+key[3]+"]";	
	}
	
	public boolean equals(Object o){
		return hashCode() == o.hashCode();
	}
	
	public int hashCode(){
		return 1000*key[0] + 100 * key[1] + 10 * key[2] + key[3];
	}
}
